<?php

if ($_SERVER['SERVER_PORT']!=443) {
	$sslport=443; //whatever your ssl port is
	$url = "https://". $_SERVER['SERVER_NAME'] . ":" . $sslport . $_SERVER['REQUEST_URI'];
	header("Location: $url");
}

//  Simple Funciton that returns a string containing a 
//  select box with each of the 50 US states and a default value "Select State"
//  You can pass in a state name as a string to select a specific State.  i.e. StateSelect('Virginia');
function StateSelect($selected = 'Select State'){
	$state['default'] = 'Select State';
	$state[AL] = "Alabama";
	$state[AK] = "Alaska";
	$state[AZ] = "Arizona";
	$state[AR] = "Arkansas";
	$state[CA] = "California";
	$state[CO] = "Colorado";
	$state[CT] = "Connecticut";
	$state[DE] = "Delaware";
	$state[FL] = "Florida";
	$state[GA] = "Georgia";
	$state[HI] = "Hawaii";
	$state[ID] = "Idaho";
	$state[IL] = "Illinois";
	$state[IN] = "Indiana";
	$state[IA] = "Iowa";
	$state[KS] = "Kansas";
	$state[KY] = "Kentucky";
	$state[LA] = "Louisiana";
	$state[ME] = "Maine";
	$state[MD] = "Maryland";
	$state[MA] = "Massachusetts";
	$state[MI] = "Michigan";
	$state[MN] = "Minnesota";
	$state[MS] = "Mississippi";
	$state[MO] = "Missouri";
	$state[MT] = "Montana";
	$state[NE] = "Nebraska";
	$state[NV] = "Nevada";
	$state[NH] = "New Hampshire";
	$state[NJ] = "New Jersey";
	$state[NM] = "New Mexico";
	$state[NY] = "New York";
	$state[NC] = "North Carolina";
	$state[ND] = "North Dakota";
	$state[OH] = "Ohio";
	$state[OK] = "Oklahoma";
	$state['OR'] = "Oregon";
	$state[PA] = "Pennsylvania";
	$state[RI] = "Rhode Island";
	$state[SC] = "South Carolina";
	$state[SD] = "South Dakota";
	$state[TN] = "Tennessee";
	$state[TX] = "Texas";
	$state[UT] = "Utah";
	$state[VT] = "Vermont";
	$state[VA] = "Virginia";
	$state[WA] = "Washington";
	$state[WV] = "West Virginia";
	$state[WI] = "Wisconsin";
	$state[WY] = "Wyoming";
	$options = '';
	foreach ($state as $value => $display)
		$options .= $display == $selected ? "\t\t<option value=\"$value\" selected>$display</option>" . PHP_EOL  
														  :	"\t\t<option value=\"$value\">$display</option>" . PHP_EOL;		
	unset($state);
	$stateSelect = "\t<select name=\"x_state\" size=\"1\">".PHP_EOL . $options . "\t</select>" . PHP_EOL;
	return $stateSelect;
}

function DisplayOrderForm(){
	$payment_url = '/process-order';
	$total = 100.99;
	$payment_form = "<form action=\"".$payment_url."\" method=\"post\" name=\"payment\">" .PHP_EOL;
	$payment_form .= '<input name="type" type="hidden" value="order" />';
	$payment_form .= '	<table class="data" border="0" cellpadding="0" cellspacing="0">'. PHP_EOL;
	$payment_form .= '		<tbody><tr class="roweven">'. PHP_EOL;
	$payment_form .= '			<th colspan="5">Payment</th>'. PHP_EOL;
	$payment_form .= '		</tr>'. PHP_EOL;
	$payment_form .= '	<tr class="roweven">'.PHP_EOL;
	$payment_form .= '				<td rowspan="4" valign="top"><strong>Pay by Credit Card</strong></td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td>Credit Card Number</td>'. PHP_EOL;
	$payment_form .= '				<td align="right"><span id="req">*</span></td>'. PHP_EOL;
	$payment_form .= '				<td>'. PHP_EOL;
	$payment_form .= '					<input name="x_card_num" size="24" type="text"></td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td>Security Code</td>'. PHP_EOL;
	$payment_form .= '				<td align="right"><span id="req">*</span></td>'. PHP_EOL;
	$payment_form .= '				<td>'. PHP_EOL;
	$payment_form .= '					<input name="x_card_code" size="4" maxlength="4" type="text" width="36"></td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;	
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td>Expiration Date</td>'. PHP_EOL;
	$payment_form .= '				<td align="right"><span id="req">*</span></td>'. PHP_EOL;
	$payment_form .= '				<td><select name="x_exp_date_m" size="1">'. PHP_EOL;
	$payment_form .= '						<option value="1">01</option>'. PHP_EOL;
	$payment_form .= '						<option value="2">02</option>'. PHP_EOL;
	$payment_form .= '						<option value="3">03</option>'. PHP_EOL;
	$payment_form .= '						<option value="4">04</option>'. PHP_EOL;
	$payment_form .= '						<option value="5">05</option>'. PHP_EOL;
	$payment_form .= '						<option value="6">06</option>'. PHP_EOL;
	$payment_form .= '						<option value="7">07</option>'. PHP_EOL;
	$payment_form .= '						<option value="8">08</option>'. PHP_EOL;
	$payment_form .= '						<option value="9">09</option>'. PHP_EOL;
	$payment_form .= '						<option value="10">10</option>'. PHP_EOL;
	$payment_form .= '						<option value="11">11</option>'. PHP_EOL;
	$payment_form .= '						<option value="12">12</option>'. PHP_EOL;
	$payment_form .= '					</select>/<select name="x_exp_date_y" size="1">'. PHP_EOL;
	$payment_form .= '						<option value="8">08</option>'. PHP_EOL;
	$payment_form .= '						<option value="9">09</option>'. PHP_EOL;
	$payment_form .= '						<option value="10">10</option>'. PHP_EOL;
	$payment_form .= '						<option value="11">11</option>'. PHP_EOL;
	$payment_form .= '						<option value="12">12</option>'. PHP_EOL;
	$payment_form .= '						<option value="13">13</option>'. PHP_EOL;
	$payment_form .= '						<option value="14">14</option>'. PHP_EOL;
	$payment_form .= '						<option value="15">15</option>'. PHP_EOL;
	$payment_form .= '						<option value="16">16</option>'. PHP_EOL;
	$payment_form .= '						<option value="17">17</option>'. PHP_EOL;
	$payment_form .= '						<option value="18">18</option>'. PHP_EOL;
	$payment_form .= '						<option value="19">19</option>'. PHP_EOL;
	$payment_form .= '						<option value="20">20</option>'. PHP_EOL;
	$payment_form .= '					</select></td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '	<tr class="roweven">'.PHP_EOL;
	$payment_form .= '				<td rowspan="8" valign="top"><strong>Cardholder Info</strong></td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;	
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td>First Name</td>'. PHP_EOL;
	$payment_form .= '				<td align="right"><span id="req">*</span></td>'. PHP_EOL;
	$payment_form .= '				<td>'. PHP_EOL;
	$payment_form .= '					<input name="x_first_name" size="24" type="text"></td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td>Last Name</td>'. PHP_EOL;
	$payment_form .= '				<td align="right"><span id="req">*</span></td>'. PHP_EOL;
	$payment_form .= '				<td>'. PHP_EOL;
	$payment_form .= '					<input name="x_last_name" size="24" type="text"></td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td>Bill to Address<br /><br /></td>'. PHP_EOL;
	$payment_form .= '				<td align="right"><span id="req">*</span><br /><br /></td>'. PHP_EOL;
	$payment_form .= '				<td>'. PHP_EOL;
	$payment_form .= '					<input name="x_address_1" size="24" type="text"><br />'. PHP_EOL;
	$payment_form .= '					<input name="x_address_2" size="24" type="text"></td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td>City</td>'. PHP_EOL;
	$payment_form .= '				<td align="right"><span id="req">*</span></td>'. PHP_EOL;
	$payment_form .= '				<td>'. PHP_EOL;
	$payment_form .= '					<input name="x_city" size="24" type="text"></td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td>State</td>'. PHP_EOL;
	$payment_form .= '				<td align="right"><span id="req">*</span></td>'. PHP_EOL;
	$payment_form .= '				<td>'. PHP_EOL;
	$payment_form .= 						StateSelect();
	$payment_form .= '				</td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td>Zip</td>'. PHP_EOL;
	$payment_form .= '				<td align="right"><span id="req">*</span></td>'. PHP_EOL;
	$payment_form .= '				<td>'. PHP_EOL;
	$payment_form .= '					<input name="x_zip" size="24" type="text"></td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td>Phone</td>'. PHP_EOL;
	$payment_form .= '				<td align="right"><span id="req">*</span></td>'. PHP_EOL;
	$payment_form .= '				<td>( <input class="tel3" size="3" maxlength="3" type="text" name="x_phone_1" />)  '. PHP_EOL;
	$payment_form .= '					<input class="tel3" size="3" maxlength="3" type="text" name="x_phone_2" /> -  '. PHP_EOL;
	$payment_form .= '					<input class="tel4" size="4" maxlength="4" type="text" name="x_phone_3" /></td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td colspan="4" height="32">'. PHP_EOL;
	$payment_form .= '				</td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td><strong>Pay by Altiris Voucher</strong></td>'. PHP_EOL;
	$payment_form .= '				<td>Voucher Code:</td>'. PHP_EOL;
	$payment_form .= '				<td>&nbsp;</td>'. PHP_EOL;
	$payment_form .= '				<td>'. PHP_EOL;
	$payment_form .= '					<input name="altiris_code" size="24" type="text"></td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td colspan="4" height="32">'. PHP_EOL;
	$payment_form .= '				</td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td><strong>Apply Redeemable</strong></td>'. PHP_EOL;
	$payment_form .= '				<td>Promotional Code:</td>'. PHP_EOL;
	$payment_form .= '				<td>&nbsp;</td>'. PHP_EOL;	
	$payment_form .= '				<td>'. PHP_EOL;
	$payment_form .= '					<input name="promo_code" size="24" type="text"></td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '			<tr class="roweven">'. PHP_EOL;
	$payment_form .= '				<td colspan="4" align="center" height="64"><input name="submit" value="Process" type="submit"/></td>'. PHP_EOL;
	$payment_form .= '			</tr>'. PHP_EOL;
	$payment_form .= '		</tbody>'. PHP_EOL;
	$payment_form .= '   		</table>'. PHP_EOL;
	$payment_form .= '	<input name="x_amount" value="'.$total.'" type="hidden" />'. PHP_EOL;
//	$payment_form .= '	<input name="x_amount" value="'.$total.'" />'. PHP_EOL;
	$payment_form .= '	</form>'. PHP_EOL;
	return $payment_form;
}



function DisplayLogin($attempts = 0){
	$limit = 10;
	$registration_url = '/index.php?page=registration';
	$login_action_url ='/index.php?page=cart-login';
	$register = '<a href='. $registration_url . '>Register</a>';
	$login_form  = '<form id="login" method="post" action="'.$login_action_url.'" enctype="multipart/form-data" style="margin: 8px; text-align: left; float: left;">';
	$login_form .= '<div class="formbuilder" style="margin: 8px; text-align: left; float: left;"><div class="required text2-0">';
	$login_form .= '		<label for="email">E-mail: <span class="required_symbol">*</span></label>';
	$login_form .= '		<input type="text" name="email" id="email" value="" size="25" maxlength="128" />';
	$login_form .= '	</div>';
	$login_form .= '	<div class="required text2-0">';
	$login_form .= '		<label for="password">Password: <span class="required_symbol">*</span></label>';
	$login_form .= '		<input type="password" name="password" id="password" value="" size="25" maxlength="128" />';
	$login_form .= '	</div>';
	$login_form .= '	<div class="submit">';
	$login_form .= '	<script type="text/javascript">';
	$login_form .= '	/* <!-- <![CDATA[ */';
	$login_form .= '    var submitted = 0;';
	$login_form .= '    function LockButton ()';
	$login_form .= '       {';
	$login_form .= '       var ret = false;';
	$login_form .= '       if ( ! submitted )';
	$login_form .= '          {';
	$login_form .= '           var item = document.getElementById("fbsubmit");';
	$login_form .= '           if (item != null)';
	$login_form .= '             {';
	$login_form .= '             setTimeout(function() {item.disabled = true}, 0);';
	$login_form .= '             }';
	$login_form .= '           submitted = 1;';
	$login_form .= '           ret = true;';
	$login_form .= '          }';
	$login_form .= '        return ret;';
	$login_form .= '        }';
	$login_form .= '    /* ]]> --> */';    
	$login_form .= '	</script><input name="submit" value="Login" type="submit" class="fbsubmit" id="fbsubmit" onclick="return LockButton()" />';
	$login_form .= '</div>';
	$login_form .= '</div>';
	$login_form .= '</form>';
	$login_form .= $attempts > 0 ? "<h3>You have attempted to login $attempts time(s)</h3>": "";	
	if(isset($attempts) && $attempts > $limit){
		return 	"<h3>Please $register or contact support for assistance</h3><br />".$_SERVER['REMOTE_ADDR'];
	}
	else{
		return "<h3>Please $register or login</h3> $login_form";
	}
}

$ini = ini_set("soap.wsdl_cache_enabled", 0);
if(!isset($_COOKIE['MySession'])){
	$url = "https://". $_SERVER['SERVER_NAME'] . "/freeway/custom/webservices/index.php?service=Session";
	$Client = new SoapClient($url);
	$this_Session = $Client->returnSID();
	setcookie('MySession', $this_Session);
	unset($Client);	
}
else 
	$this_Session = $_COOKIE['MySession'];

	
//print_r($_SESSION);
if(isset($_POST[email]) && isset($_POST[password])){
	$email = $_POST[email];
	$password = $_POST[password];
	$url = "https://". $_SERVER['SERVER_NAME'] . "/freeway/custom/webservices/index.php?service=Customer";
	$Client = new SoapClient($url);
	$Client->__setCookie('ws_freeway', $this_Session);
	$attempt = $Client->Login($password, $email);
	if(!isset($attempt[Error])){
		$_SESSION['cart']['customer_id'] = $attempt[customer_id];
	}
}

if(!isset($attempt[ERROR]) && isset($_SESSION['cart']['customer_id'])){
	$url_cart = "https://". $_SERVER['SERVER_NAME'] . "/freeway/custom/webservices/index.php?service=ShoppingCart";
	$Cart = new SoapClient($url_cart);
	$Cart->__setCookie('ws_freeway', $this_Session);
	$Cart->__setCookie('customer_id', $_SESSION['cart']['customer_id']);
	if((isset($_REQUEST[item]) && $_REQUEST[item] !=null) && (isset($_REQUEST[session]) && $_REQUEST[session] != null)){
		$item = $_GET[item];
		$item_session = $_GET[session];
		$products_id = $item;
		$customers_basket_quantity = 1;
		$products_type = 'E';
		$old_orders_id = 0;
		$answer_type = null;
		$answer_value = null;
		$session_id = $item_session;
		$debug = $Cart->CustomerBasketAdd($products_id, $customers_basket_quantity, $products_type, $old_orders_id, $answer_type, $answer_value, $session_id);
	echo "<pre>";
	print_r($debug);
	echo "</pre>";
		
	}	
	
	$cart_contents = $Cart->getCustomerCart();
	$count = 0;
	$total = 0;
	$startTable =	isset($debug[booked]) ?'<h2>'.$debug[booked].'</h2><h3>Your Cart</h3><table class="data" border="0" cellspacing="0" cellpadding="0">' .PHP_EOL : '<h3>Your Cart</h3><table class="data" border="0" cellspacing="0" cellpadding="0">' .PHP_EOL;
	$startTable .= '<tr>' .PHP_EOL;
	$startTable .= '<th nowrap="nowrap" colspan="2">Course</th>' .PHP_EOL;
	$startTable .= '<th nowrap="nowrap" colspan="2">Date</th>' .PHP_EOL;
	$startTable .= '<th nowrap="nowrap" colspan="2">Location</th>' .PHP_EOL;
	$startTable .= '<th nowrap="nowrap" colspan="2">Qty</th>' .PHP_EOL;
	$startTable .= '<th nowrap="nowrap" colspan="2">Price</th>' .PHP_EOL;
	$startTable .= '<th nowrap="nowrap" colspan="2" align="left">Total</th>' .PHP_EOL;
	$startTable .= '</tr><tbody>';
	echo $startTable;
	$display = "";
	$js_totals = '<script type="text/javascript">'.PHP_EOL;
	$js_totals .= '<!-- /* <![CDATA[ */  '.PHP_EOL;	
	$js_totals .= 	'function convertIt(_a) { var _c = _a; var _x = _a.indexOf("$"); if (_x == -1 ) _x = _a.indexOf(","); if (_x != -1) { var _p1 = _a.substr(0,_x); var _p2 = _a.substr(_x+1,_a.length); _c = convertIt(_p1+_p2);  }  return (_c);} '.PHP_EOL;
	$js_totals .= 'function updateCart(price, session_id, customer_id, count, product_id){ ' .PHP_EOL;
	$js_totals .= 'var subtotal = 0; ';
	$js_totals .= 'var myval = "$"; ';
	$js_totals .= 'myval = jQuery("#item_"+count+"_total").html(); '.PHP_EOL;
	$js_totals .= '	subtotal = parseFloat(convertIt(myval)); '.PHP_EOL;
	$js_totals .= '	total = subtotal /parseFloat(price); '.PHP_EOL;
	$js_totals .= '	total = parseFloat(jQuery("#item_"+count).val()) - total;  '.PHP_EOL;	
	$js_totals .= '	var returned = "";'.PHP_EOL;
	$js_totals .= '	if(total > 0){ ';
	$js_totals .= '		returned = jQuery.post("/ajaxCart", { customer_id: customer_id, products_id: product_id, total: total, this_Session: "'.$this_Session.'", session_id: session_id, action: "add" }); '.PHP_EOL;
	$js_totals .= '	}'.PHP_EOL;
	$js_totals .= '	if(total < 0){'.PHP_EOL;
	$js_totals .= '		returned = jQuery.post("/ajaxCart", { customer_id: customer_id, products_id: product_id, total: Math.abs(total), this_Session: "'.$this_Session.'", session_id: session_id, action: "remove" }); '.PHP_EOL;
	$js_totals .= '	}'.PHP_EOL;
	$js_totals .= '	var temp = "hello world";'.PHP_EOL;
	$js_totals .= '	}'.PHP_EOL;
	
	foreach ($cart_contents["cart"] as $event){
		$row_type = ($count++ % 2 == 0) ? 'roweven': 'rowodd';
		$dates = explode(',',strip_tags($event[events_description]));
		$start = strip_tags(trim(str_replace('&nbsp;', '', $dates[0])));
		$end = strip_tags(trim(str_replace('&nbsp;', '', $dates[1])));
		$range = str_replace('&nbsp;', '', $start . ' - ' . $end);
		$range = trim($range);
		$price = "$".money_format('%i', $event[events_fees]);
		$row_sum = 
		$total = (int)$total + (int)$event[events_fees]*$event[qnty]; 
		$location = explode(',', $event[location_name]);
		$location1 = $location[0];
		$location2 = $location[1];
		$url = 'https://eden.iwsdev.com/training';
		$title = $event[events_categories_name];
		$qnty = $event[qnty];
		$product_session_id = $event[sessions_id]; 
		$row_sum = "$".money_format('%i', ($event[events_fees]*$event[qnty]));
		$register_url = 'https://'. $_SERVER['SERVER_NAME'] . '/register-course?item='.$event[events_id].'&session='.$event[sessions_id];
		
		$display .= "<tr class=".$row_type.">" .PHP_EOL;
		$display .= "<td colspan=\"2\">$title</td>" .PHP_EOL;
		$display .= "<td colspan=\"2\">$range</td>" .PHP_EOL;
		$display .= "<td colspan=\"2\"><a href=".$url.">$location1,&nbsp;$location2</a></td>" .PHP_EOL;
		$display .= "<td colspan=\"2\"><input id=\"item_$count\" name=\"qnty\" value=\"$qnty\" size=\"2\" type=\"text\" width=\"24\" /></td>" .PHP_EOL;
		$display .= "<td colspan=\"2\" id=\"item_".$count."_price\" >$price</td>" .PHP_EOL;
		$display .= "<td colspan=\"2\" id=\"item_".$count."_total\" >$row_sum</td>" .PHP_EOL;
		$display .= "</tr>" .PHP_EOL;



		$js_totals .= 'jQuery(\'#item_'.$count.'\').keyup(function(){jQuery("#item_'.$count.'").val(Math.round(jQuery("#item_'.$count.'").val())); price = convertIt(jQuery("#item_'.$count.'_price").html()); updateCart(price, '.$product_session_id.', '.$_SESSION['cart']['customer_id'].', '.$count.', '.$event[events_id].'); total = price * jQuery("#item_'.$count.'").val(); jQuery("#item_'.$count.'_total").html("$" + total.toFixed(2)); updateSubTotal();}); '.PHP_EOL;
		$jq_selector_group[] = "#item_".$count."_total";
	}
	$js_totals .= ' function updateSubTotal(){mysum = 0; jQuery("'.implode(', ', $jq_selector_group).'").each(function(i){mysum+= parseFloat(convertIt(this.innerHTML));}); jQuery("#final_total").html("$" + parseFloat(mysum).toFixed(2));} ';	
	
	$js_totals .= ' /* ]]> */ //-->'.PHP_EOL;
	$js_totals .= '</script>'.PHP_EOL;
	echo $display;
	$total = "$".money_format('%i', $total);	
	$EndTable ='	<tr class="roweven">' .PHP_EOL;
	$EndTable .='		<td colspan="12"><a href="'.$url.'">Register more courses...</a></td>' .PHP_EOL;
	$EndTable .='	</tr>' .PHP_EOL;
	$EndTable .='	<tr class="roweven">' .PHP_EOL;
	$EndTable .='		<td colspan="10" align="right"><strong>Sub Total</strong></td>' .PHP_EOL;
	$EndTable .='		<td>&nbsp;</td>' .PHP_EOL;
	$EndTable .='		<td><strong id="final_total">'.$total.'</strong></td>' .PHP_EOL;
	$EndTable .='	</tr>' .PHP_EOL;

	echo $EndTable .'</tbody></table>';
	echo '<br />';
	echo '<br />';
	echo DisplayOrderForm();
	echo $js_totals;
}
else {
	if(isset($attempt[ERROR])){
		$_SESSION[failedLogin] = isset($_SESSION[failedLogin]) ? $_SESSION[failedLogin]++: 1;
		echo '<h3>'.$attempt[ERROR].'</h3>';
	}
	echo DisplayLogin();
}
/*
echo '<pre>';
print_r($cart_contents);
echo '<hr />';
print_r($_COOKIE);
print_r($Client->__cookies);
print_r($_SESSION);
echo '</pre>';
*/


?>